cmake_minimum_required(VERSION 2.8)

project(libAudio)
message(STATUS "Project name : --- ${PROJECT_NAME}")

message(STATUS "Current dir : --- ${CMAKE_CURRENT_SOURCE_DIR}")

# CMAKE_BUILD_TYPE = Debug Release RelWithDebInfo MinSizeRel
# 固定设置为Debug，在本项目中最终发布的版本也是在Debug版本的集成上进行Strip。
# 详见HUNTER_RELEASE参数
set(CMAKE_BUILD_TYPE Release)

#-----------------------------------------------------------------------------
# 配置平台参数
if (NOT CROSS_PLATFORM)
	set(CROSS_PLATFORM RV1126)
endif ()
message(STATUS "CROSS_PLATFORM : --- ${CROSS_PLATFORM}")

#-----------------------------------------------------------------------------

# 包含平台通用编译规则，为了那些跨平台代码，采用公共且唯一的allRules.cmake。
# 约定allRules.cmake，一般位于项目目录的向上三层目录内。
if (EXISTS ${PROJECT_SOURCE_DIR}/build/Rules/allRules.cmake)
	include(${PROJECT_SOURCE_DIR}/build/Rules/allRules.cmake)
else ()
	message(FATAL_ERROR "Can't include allRules.cmake")
endif ()

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g")

if (UNSUPPORT_AAC)
	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUNSUPPORT_AAC")
endif ()

if (UNSUPPORT_IAS)
else ()
	#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DBUILD_IAS")
endif ()

if (${CROSS_PLATFORM} STREQUAL HI3516A)
	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DHIMPP_V2_0")
	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DAUDIO_HI3516A")
elseif (${CROSS_PLATFORM} STREQUAL HI3519)
	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DHIMPP_V2_0")
	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DAUDIO_HI3519")
	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUNSUPPORT_AAC")
elseif (${CROSS_PLATFORM} STREQUAL HI3519V101)
	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DHIMPP_V2_0")
	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DAUDIO_HI3519V101")
elseif (${CROSS_PLATFORM} STREQUAL HI3516CV300)
	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DHIMPP_V2_0")
	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DAUDIO_HI3516CV300")
elseif (${CROSS_PLATFORM} STREQUAL HI3518EV200)
	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DHIMPP_V2_0")
	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DAUDIO_HISI_V200")
elseif (${CROSS_PLATFORM} STREQUAL HI3559AV100)
	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DHIMPP_V2_0")
	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DAUDIO_HI3559AV100")
elseif (${CROSS_PLATFORM} STREQUAL HI3516CV500)
	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DHIMPP_V2_0")
	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DAUDIO_HI3516CV500")
	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUNSUPPORT_AAC")
elseif (${CROSS_PLATFORM} STREQUAL HI3516DV300)
	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DHIMPP_V2_0")
	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DAUDIO_HI3516CV500")
	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUNSUPPORT_AAC")
elseif (${CROSS_PLATFORM} STREQUAL HI3516EV200)
	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DHIMPP_V2_0")
	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DAUDIO_HI3516EV200")
	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUNSUPPORT_AAC")	
elseif (${CROSS_PLATFORM} STREQUAL HI3519AV100)
	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DHIMPP_V2_0")
	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DAUDIO_HI3519AV100")
	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUNSUPPORT_AAC")
elseif (${CROSS_PLATFORM} STREQUAL HI3518C)
else ()
endif ()


add_definitions(-DHAVE_CONFIG_H)

add_subdirectory(src)
